cmake_minimum_required(VERSION 3.5)
project(ji)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_INSTALL_PREFIX "/usr/local/ev_sdk")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

link_libraries(asan)

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer ")
set (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address  -lasan -lstdc++ ")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address  -lasan -lstdc++ ")



set(ADDITIONAL_RPATH "/opt/intel/openvino/deployment_tools/ngraph/lib:\
/opt/intel/opencl:\
/opt/intel/openvino/deployment_tools/inference_engine/external/hddl/lib:\
/opt/intel/openvino/deployment_tools/inference_engine/external/gna/lib:\
/opt/intel/openvino/deployment_tools/inference_engine/external/mkltiny_lnx/lib:\
/opt/intel/openvino/deployment_tools/inference_engine/external/tbb/lib:\
/opt/intel/openvino/deployment_tools/inference_engine/lib/intel64")

# 使用pkg-config查找必要的依赖包
find_package(OpenCV REQUIRED)
#find_library(glog REQUIRED)
set(ENV{PKG_CONFIG_PATH} "ENV{PKG_CONFIG_PATH}")
find_package(PkgConfig REQUIRED)
set(InferenceEngine_DIR "/opt/intel/openvino/deployment_tools/inference_engine/share")
find_package(InferenceEngine 2.1)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rd/cJSON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rd/wkt_parser)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:/usr/local/ev_sdk/lib")

# 编译libji.so
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SRCS)

list(APPEND libji_SOURCES
        ${SRCS})

add_library (${PROJECT_NAME} SHARED ${libji_SOURCES})

target_link_libraries(${PROJECT_NAME}
-static-libasan
        ${OpenCV_LIBS}
        glog
        cjson
        WKTParser
        ${InferenceEngine_LIBRARIES}
       # asan
       
        )
target_include_directories(${PROJECT_NAME}
        PUBLIC ${OpenCV_INCLUDE_DIR}
        PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
        PUBLIC ${InferenceEngine_INCLUDE_DIRS})
# Install libji.so
install(TARGETS ${PROJECT_NAME} DESTINATION lib)


